import React, { useEffect } from 'react'
import { useHistory } from 'react-router-dom'
import Nav from './components/Nav'
import Loading from './components/Loading'
import { Provider } from 'react-redux'
import store from './store'
import Alert from './components/Alert'

export default function App(props) {
    let history = useHistory();

    useEffect(() => {
        if (history.location.pathname === '/') {
            history.push('/home')
        }
    }, [])// eslint-disable-line

    return (
        <>
            <Provider store={store}>
                <Alert />
                <>{props.children}</>
                <Loading />
            </Provider>
            <Nav history={history} />
        </>
    )
}
